In This Topic
Programming / Document Loading & Saving / Saving PDF documents

Saving PDF documents

In This Topic

Say you have processed your PDF document, here is what you have to do to save it:

Copy Code
'We assume that GdPicture has been correctly installed and unlocked.

Using oGdPicturePDF As New GdPicturePDF()

    Dim status As GdPictureStatus = oGdPicturePDF.LoadFromFile("test.pdf", True) 'The file is loaded into memory.

    If status = GdPictureStatus.OK Then

        If oGdPicturePDF.ClonePage(1) = GdPictureStatus.OK Then 'Processing...

            status = oGdPicturePDF.SaveToFile("test.pdf") 'The file is overwritten.

            If status = GdPictureStatus.OK Then

                MessageBox.Show("The PDF file has been overwritten and saved sucessfully.", "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Information)

            Else

                MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Error)

            End If

            oGdPicturePDF.CloseDocument()

        End If

    Else

        MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Error)

    End If

End Using
Copy Code
//We assume that GdPicture has been correctly installed and unlocked.

using (GdPicturePDF oGdPicturePDF = new GdPicturePDF())

{

    GdPictureStatus status = oGdPicturePDF.LoadFromFile("test.pdf", true); //The file is loaded into memory.

    if (status == GdPictureStatus.OK)

    {

        if (oGdPicturePDF.ClonePage(1) == GdPictureStatus.OK) //Processing...

        {

            status = oGdPicturePDF.SaveToFile("test.pdf"); //The file is overwritten.

            if (status == GdPictureStatus.OK)

            {

                MessageBox.Show("The PDF file has been overwritten and saved sucessfully.", "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            else

            {

                MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }

            oGdPicturePDF.CloseDocument();

        }

    }

    else

    {

        MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Error);

    }

}